#ifndef __TIMER_H__
#define __TIMER_H__

#include "unione_lite.h"

#define TIMER1        0
#define TIMER2        1
#define TIMER3        2

#define RTOS_TIMER_BASE     TMR_FTTMR010_PA_BASE

#define TMR_CNTER(x)             (RTOS_TIMER_BASE + 0x0 + 0x10 * (x))
#define TMR_LOAD(x)               (RTOS_TIMER_BASE + 0x4 + 0x10 * (x))
#define TMR_MATCH1(x)           (RTOS_TIMER_BASE + 0x8 + 0x10 * (x))
#define TMR_MATCH2(x)           (RTOS_TIMER_BASE + 0xC + 0x10 * (x))
#define TMR_CTRL                    (RTOS_TIMER_BASE + 0x30)
#define TMR_INT_STATUS         (RTOS_TIMER_BASE + 0x34)
#define TMR_INT_MASK           (RTOS_TIMER_BASE + 0x38)


/* for Timer Control Register */
#define	FTTMR_TM1_ENABLE	(1 << 0)
#define	FTTMR_TM1_CLOCK		(1 << 1)
#define	FTTMR_TM1_OFENABLE	(1 << 2)
#define	FTTMR_TM2_ENABLE	(1 << 3)
#define	FTTMR_TM2_CLOCK		(1 << 4)
#define	FTTMR_TM2_OFENABLE	(1 << 5)
#define	FTTMR_TM3_ENABLE	(1 << 6)
#define	FTTMR_TM3_CLOCK		(1 << 7)
#define	FTTMR_TM3_OFENABLE	(1 << 8)
#define	FTTMR_TM1_UPDOWN	(1 << 9)
#define	FTTMR_TM2_UPDOWN	(1 << 10)
#define	FTTMR_TM3_UPDOWN	(1 << 11)

	/* for Timer Interrupt State & Mask Registers */
#define	FTTMR_TM1_MATCH1	(1 << 0)
#define	FTTMR_TM1_MATCH2	(1 << 1)
#define	FTTMR_TM1_OVERFLOW	(1 << 2)
#define	FTTMR_TM2_MATCH1	(1 << 3)
#define	FTTMR_TM2_MATCH2	(1 << 4)
#define	FTTMR_TM2_OVERFLOW	(1 << 5)
#define	FTTMR_TM3_MATCH1	(1 << 6)
#define	FTTMR_TM3_MATCH2	(1 << 7)
#define	FTTMR_TM3_OVERFLOW	(1 << 8)


#define TMR_CLOCK_HZ	  TMR_CLK

//extern void init_jiffies_timer(void);
extern void timer_ctrl(u32 id, u32 int_en, u32 start);
extern int timer_prepare_for_os(u32 tick_hz);
extern int enable_timer(int TimerIdx);
extern int disable_timer(int TimerIdx);
extern int timer_Config(int TimerIdx,u32 usec,void (*timer_cb)(int TimerIdx));
#endif /*__TIMER_H__*/
